//
//  BM_WeightResultVC.m
//  BaoYouYou
//
//  Created by MZY on 16/12/4.
//  Copyright © 2016年 caobo56. All rights reserved.
//

#import "BM_WeightResultVC.h"
#import "BM_LineView.h"

@interface BM_WeightResultVC (){
    UIImageView *imageV;
}
@property (nonatomic, strong) NSMutableArray *s_array;
@property (nonatomic, strong) NSMutableArray *array1;
@property (nonatomic, strong) NSMutableArray *array2;
@property (nonatomic, strong) UILabel *resultLabel;
@property (nonatomic) int s_mix;

@end

@implementation BM_WeightResultVC

-(void)createView{
    BM_LineView *lineView = [[BM_LineView alloc]init];
    lineView.s_mix = _s_mix;
    lineView.s_array = _s_array;
    lineView.array1 = _array1;
    lineView.array2 = _array2;
    [lineView createView];
    lineView.top = 64+10;
    [self.view addSubview:lineView];

    imageV = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"boy_girl"]];
    imageV.top = lineView.bottom+rateWidth(30);
    imageV.width = WidthOfScreen - rateWidth(50)*2;
    imageV.height = 40;
    imageV.centerX = WidthOfScreen/2;
    [self.view addSubview:imageV];

    _resultLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, WidthOfScreen, 30)];
    _resultLabel.centerY = imageV.centerY;
    _resultLabel.textAlignment = NSTextAlignmentCenter;
    float difference = [_array1[0] floatValue] - [_array2[0] floatValue];
    _resultLabel.numberOfLines = 0;
    _resultLabel.text= [NSString stringWithFormat:@"当前孕周的体重:%@g\n偏离参考值:%.fg",_array1[0],difference];
    _resultLabel.textColor = UIColorFromRGB(0X1a1a1a);
    _resultLabel.font = [UIFont systemFontOfSize:15];
    [_resultLabel sizeToFit];
    _resultLabel.center = imageV.center;
    [self.view addSubview:_resultLabel];

    UILabel *label = [[UILabel alloc]initWithFrame:CGRectZero];
    label.textAlignment = NSTextAlignmentLeft;
    label.numberOfLines = 0;
    label.text= @"免责声明：由于B超测量本身误差或胎儿个体差异，上述结果\n仅供初步筛查用，不能当做医学诊断依据。";
    label.textColor = UIColorFromRGB(0X999999);
    label.font = [UIFont systemFontOfSize:11];
    [label sizeToFit];
    label.centerX = WidthOfScreen/2;
    label.top = imageV.bottom+rateWidth(20);
    [self.view addSubview:label];

}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStyleDone target:nil action:nil];
    self.navigationItem.title = @"胎儿体重预测";
    self.view.backgroundColor = UIColorFromRGB(0Xf1f2f3);
    [self createView];
}


-(void)setResultInfo:(NSDictionary *)resultInfo{
    _resultInfo = resultInfo;
    _s_array = [[NSMutableArray alloc]initWithCapacity:5];
    _array1 = [[NSMutableArray alloc]initWithCapacity:5];
    _array2 = [[NSMutableArray alloc]initWithCapacity:5];
    _s_mix = [resultInfo[@"minAxis"] intValue];
    [_s_array addObject:[NSString stringWithFormat:@"%ld",[resultInfo[@"firstAxis"] longValue]]];
    [_s_array addObject:[NSString stringWithFormat:@"%ld",[resultInfo[@"secondAxis"] longValue]]];
    [_s_array addObject:[NSString stringWithFormat:@"%ld",[resultInfo[@"thridAxis"] longValue]]];
    [_s_array addObject:[NSString stringWithFormat:@"%ld",[resultInfo[@"fourthAxis"] longValue]]];
    [_s_array addObject:[NSString stringWithFormat:@"%ld",[resultInfo[@"maxAxis"] longValue]]];

    [_array1 addObject:[NSString stringWithFormat:@"%.f",[resultInfo[@"weightProbNow"] floatValue]]];
    [_array1 addObject:[NSString stringWithFormat:@"%.f",[resultInfo[@"weightProb1Week"] floatValue]]];
    [_array1 addObject:[NSString stringWithFormat:@"%.f",[resultInfo[@"weightProb2Week"] floatValue]]];
    [_array1 addObject:[NSString stringWithFormat:@"%.f",[resultInfo[@"weightProb3Week"] floatValue]]];
    [_array1 addObject:[NSString stringWithFormat:@"%.f",[resultInfo[@"weightProb4Week"] floatValue]]];

    [_array2 addObject:[NSString stringWithFormat:@"%.f",[resultInfo[@"referWeightNow"] floatValue]]];
    [_array2 addObject:[NSString stringWithFormat:@"%.f",[resultInfo[@"referWeight1Week"] floatValue]]];
    [_array2 addObject:[NSString stringWithFormat:@"%.f",[resultInfo[@"referWeight2Week"] floatValue]]];
    [_array2 addObject:[NSString stringWithFormat:@"%.f",[resultInfo[@"referWeight3Week"] floatValue]]];
    [_array2 addObject:[NSString stringWithFormat:@"%.f",[resultInfo[@"referWeight4Week"] floatValue]]];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
